package com.xmim.core.session;

import com.xmim.core.exception.SessionrException;

import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

public interface SessionPipeline extends SessionHandleContext {

    SessionPipeline add(String name, SessionHandle handler);

    SessionPipeline add(SessionHandle... handlers);

    SessionPipeline remove(SessionHandle handler);

    SessionHandle remove(String name);

    <T extends SessionHandle> T remove(Class<T> handlerType);

    SessionHandle get(String name);

    <T extends SessionHandle> T get(Class<T> handlerType);

    SessionHandleContext context(SessionHandle handler);

    SessionHandleContext context(String name);

    SessionHandleContext context(Class<? extends SessionHandle> handlerType);

    Session session();

    List<String> names();

    Map<String, SessionHandle> toMap();

    @Override
    void fireAdded() throws Exception;

    @Override
    void fireRemoved() throws Exception;

    @Override
    void fireRead(Object msg) throws Exception;

    @Override
    void fireClose() throws Exception;

    @Override
    void fireHeartbeat(Object msg) throws Exception;

    @Override
    void fireException(Throwable cause) throws Exception;

    @Override
    void fireReadComplete() throws Exception;

    @Override
    void fireWriteComplete() throws Exception;
}
